﻿using Coldairarrow.Business;
using Coldairarrow.Entity;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers
{
    [Route("/BTB_Comment/[controller]/[action]")]
    public class BTB_CommentController : BaseApiController
    {
        #region DI
        public BTB_CommentController(IBTB_CommentBusiness bTB_CommentBus)
        {
            _bTB_CommentBus = bTB_CommentBus;
        }

        private IBTB_CommentBusiness _bTB_CommentBus { get; }

        #endregion DI

        #region 获取

        [HttpPost]
        public async Task<PageResult<BTB_Comment>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _bTB_CommentBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<BTB_Comment> GetTheData(IdInputDTO input)
        {
            return await _bTB_CommentBus.GetTheDataAsync(input.id);
        }

        /// <summary>
        /// 获取评论(列表)
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageResult<BTB_CommentdTO>> GetDataForeList(PageInput<BTB_Comment> input)
        {
            return await _bTB_CommentBus.GetDataForeListAsync(input);
        }

        /// <summary>
        /// 获取评论
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageResult<BTB_CommentdTO>> GetDataTwoList(PageInput<BTB_Comment> input)
        {
            return await _bTB_CommentBus.GetDataTwoListAsync(input);
        }

        /// <summary>
        /// 审核内容
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task UpdateDataTwo(List<BTB_CommenTwo> ids)
        {
            await _bTB_CommentBus.UpdateDataTwoAsync(ids);
        }

        /// <summary>
        /// 获取评论(前端)
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [NoCheckJWT]
        public async Task<PageResult<BTB_CommentdTO>> GetDataThreeListAsync(PageInput<BTB_Comment> input)
        {
            return await _bTB_CommentBus.GetDataThreeListAsync(input);
        }

        /// <summary>
        /// 统计(评论)
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet]
        [NoCheckJWT]
        public BTB_CommentD Getsatisfaction(string Id)
        {
            return  _bTB_CommentBus.Getsatisfaction(Id);
        }
           
        #endregion 获取

           
        #region 提交

        [HttpPost]
        public async Task SaveData(BTB_Comment data)
        {
            //if (data.Id.IsNullOrEmpty())
            //{

                data.Deleted = false;
                data.State = 0;
                InitEntity(data);

                await _bTB_CommentBus.AddDataAsync(data);
            //}
            //else
            //{
            //    await _bTB_CommentBus.UpdateDataAsync(data);
            //}
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _bTB_CommentBus.DeleteDataAsync(ids);
        }

        #endregion 提交
    }
}